package com.core.controller;

import com.core.service.OrderService;
import com.core.service.StockService;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author SunChangSheng
 * @apiNote 下单
 * @since 2021/9/22 17:37
 */

@RestController
@RequestMapping("pay")
public class PayController {
    @Autowired
    private OrderService orderService;
    @Autowired
    private StockService stockService;

    @GlobalTransactional
    @RequestMapping("order")
    public boolean payOrder() {
        System.out.println("进行下单");
        orderService.addOrder();
        stockService.reduce();
        return true;
    }
}
